<template>
  <div class="tab-control">
    <div v-for="(item, index) in tabItems" :key="index"
         class="tab-control-item" :class="{tabControlItemActive: currentIndex === index}"
         @click="showIndex(index)">
      <span>{{item}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabControl",
  props: {
    tabItems: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      currentIndex: 0
    }
  },
  methods: {
    showIndex(index) {
      this.$emit('tabClick', index);
    }
  }
}
</script>

<style scoped>
  .tab-control {
    display: flex;
    height: 44px;
    line-height: 44px;
  }
  .tab-control-item {
    flex: 1;
    text-align: center;
  }
  .tabControlItemActive {
    color: var(--color-high-text);
  }
  .tabControlItemActive span {
    padding: 4px;
    border-bottom: 2px solid var(--color-high-text);
  }
</style>